function []= FFTplot(static,yaw,pitch,stimulusFreq,Fs,excludeTrial)
%---input---
%static：静止数据，第一个维度为session，第二个维度为stimulus，第三个维度为trial，第四个维度为channel，第五个维度为samplepoints
%yaw：偏航数据，数据格式同上
%pitch：俯仰数据，数据格式同上
%stimulusFreq：刺激频率，e.g.[6.67 12.0 10.0 8.57]
%Fs：采样率
%excludeTrial: 移除的trial，每一行表示一个trial，格式为[stimulus condition session trial]
%---output---


for stimulus = 1:4
    figure;  %画图
    for condition = 1:3
        switch condition
            case 1
                SSVEPdata = static;
            case 2
                SSVEPdata = yaw;
            case 3
                SSVEPdata = pitch;
        end
        fft_session = [];
        for session = 1:size(SSVEPdata,1)
            fft_trial = [];
            avl_trial_index = 0;
            for trial = 1:size(SSVEPdata,3)
                %移除错误数据
                avl_trial_flag = 1;
                for i = 1:size(excludeTrial,1)
                    excludei = excludeTrial(i,:);
                    if(all([stimulus condition session trial] == excludei))
                        avl_trial_flag = 0;
                        break;
                    end
                end
                if(~avl_trial_flag)
                    continue;
                end
                avl_trial_index = avl_trial_index + 1;
                epoch = SSVEPdata(session,stimulus,trial,:,:);
                epoch = reshape(epoch,size(SSVEPdata,4),size(SSVEPdata,5));
                [fft_trial(avl_trial_index,:,:),f] = fast_fourier_transform(epoch',Fs);
                fft_session(session,:,:) = mean(fft_trial,1);
            end%trial
        end%session
        fft_condition = mean(fft_session,[1,3]);
        fft_condition = reshape(fft_condition,1,[]);
        plot(f,fft_condition,'linewidth',2);
        hold on;
    end
    xlabel('Frequency [Hz]');
    ylabel('Amplitude [\muV]');
    legend('static','yaw','pitch');
    axis([3 30 0 150]);
    title(['Amplitude spectra of SSVEPs in repose to the ',num2str(stimulusFreq(stimulus)),' Hz stimuli']);
    set(gca, 'linewidth', 2, 'fontsize', 20, 'fontname', 'times');
end
end

